package DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import MODEL.Emprestimo;

public class EmprestimoDAO {
	public boolean cadastrodeEmprestimo(Emprestimo emprestimo) throws SQLException{
		boolean status=false;
		Connection conn = null;
		PreparedStatement stmt = null;
		Conexao com = new Conexao();
		
			try
			{
				conn = com.getConnection();
			} catch (InstantiationException e) {
				
				e.printStackTrace();
				
			} catch (Throwable e) {
				
				e.printStackTrace();
			}
			try{
			stmt = conn.prepareStatement("INSERT INTO emprestimos(IdAnimal,IdProdutor,IdTecnico) value(?,?,?)");
			stmt.setInt(1,emprestimo.getIdAnimal());
			stmt.setInt(2,emprestimo.getIdProdutor());
			stmt.setInt(3,emprestimo.getIdTecnico());
			stmt.executeUpdate();
			status=true;
			}
			catch (Exception e) {
				e.printStackTrace();
			}
		
		return status;
	}
		
	}
